package com.dyna.web.tx.controller;

import com.dyna.web.tx.service.TxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("demo模块/事务")
@RestController
@RequestMapping("/tx")
public class TxController {

    private final TxService txService;

    public TxController(TxService txService) {
        this.txService = txService;
    }

    @ApiOperation("正常事务场景")
    @GetMapping("/normalTransactionalScene")
    public void normalTransactionalScene() {
        txService.normalTransactionalScene();
    }

    @ApiOperation("事务回滚场景")
    @GetMapping("/rollbackTransactionalScene")
    public void rollbackTransactionalScene() {
        txService.rollbackTransactionalScene();
    }

    @ApiOperation("事务回滚失效场景1")
    @GetMapping("/rollbackTransactionalFailScene1")
    public void rollbackTransactionalFailScene1() {
        txService.rollbackTransactionalFailScene1();
    }

}
